using System;
using AndyPike.Snowflake.Core.Mappers;
using AndyPike.Snowflake.Core.Messages;
using AndyPike.Snowflake.Entities;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;

namespace AndyPike.Snowflake.Core.Tests.Unit.Mappers
{
    [TestFixture]
    public class When_mapping_an_registration_to_an_account
    {
        private RegistrationMessageToAccountMapper mapper;

        [SetUp]
        public void SetUp()
        {
            mapper = new RegistrationMessageToAccountMapper();
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Should_throw_an_exception_if_the_message_is_null()
        {
            mapper.Map(null);
        }

        [Test]
        public void Should_map_successfully_given_a_valid_message()
        {
            Account account = mapper.Map(new RegistrationMessage{UserName = "andypike", Password = "123456", Email = "someone@somewhere.com"});
            
            Assert.That(account.UserName, Is.EqualTo("andypike"));
            Assert.That(account.Password, Is.EqualTo("E10ADC3949BA59ABBE56E057F20F883E")); 
            Assert.That(account.Email, Is.EqualTo("someone@somewhere.com"));
        }
    }
}